import {STORE} from '../type';
import {createReducer} from '../'

const initialState = {
    // 搜索到的商品列表
    searchGoodsList: [],
    skuInfo: [],
    specStore: {},
    clerkList: [],
    orderList:[],
    orderDetail:'',
    orderBalanceDetail:'',
    orderBalanceList:[],
    stockList:[],
    cashList:[],
    shopList: {
        shops: [],
        years: [],
        seasons: [],
        brandList: [],
        allCategories: []
    },
    pointProportion: '',
    discountInfo: '',
    productDataHistoryList: [], // 历史记录列表
    productDataHistoryDetailList: [], // 历史记录详情列表
    inventoryHistoryList: [],  // 库存盘点历史记录列表
    inventoryHistoryDetailList: [], // 库存盘点历史记录详情列表
    transferHistoryList: [], // 库存调拨历史记录列表
    transferHistoryDetailList: [] // 库存调拨历史记录详情列表
};

const actionHandler = {
    [STORE.SEARCH_GOODS_LIST]: (state, action) => {
        return {
            ...state,
            searchGoodsList: action.res
        }
    },
    [STORE.SKU_INFO]: (state, action) => {
        return {
            ...state,
            skuInfo: action.res
        }
    },
    [STORE.SPEC_STORE]: (state, action) => {
        return {
            ...state,
            specStore: action.res
        }
    },
    [STORE.CLERK_LIST]: (state, action) => {
        return {
            ...state,
            clerkList: action.res
        }
    },
    [STORE.ORDER_LIST]: (state, action) => {
        return {
            ...state,
            orderList: action.res
        }
    },
    [STORE.ORDER_BALANCE_LIST]: (state, action) => {
        return {
            ...state,
            orderBalanceList: action.res
        }
    },
    [STORE.ORDER_DETAIL]: (state, action) => {
        return {
            ...state,
            orderDetail: action.res
        }
    },
    [STORE.ORDER_BALANCE_DETAIL]: (state, action) => {
        return {
            ...state,
            orderBalanceDetail: action.res
        }
    },
    [STORE.STOCK_LIST]: (state, action) => {
        return {
            ...state,
            stockList: action.res
        }
    },
    [STORE.CASH_LIST]: (state, action) => {
        return {
            ...state,
            cashList: action.res
        }
    },
    [STORE.SHOP_LIST]: (state, action) => {
        return {
            ...state,
            shopList: action.res
        }
    },
    [STORE.POINT_PROPORTION]: (state, action) => {
        return {
            ...state,
            pointProportion: action.res
        }
    },
    [STORE.DISCOUNT_INFO]: (state, action) => {
        return {
            ...state,
            discountInfo: action.res
        }
    },
    [STORE.PRODUCT_DATA_HISTORY_LIST]: (state, action) => {
        return {
            ...state,
            productDataHistoryList: action.res
        }
    },
    [STORE.PRODUCT_DATA_HISTORY_DETAIL_LIST]: (state, action) => {
        return {
            ...state,
            productDataHistoryDetailList: action.res
        }
    },
    [STORE.INVENTORY_HISTORY_LIST]: (state, action) => {
        return {
            ...state,
            inventoryHistoryList: action.res
        }
    },
    [STORE.INVENTORY_HISTORY_DETAIL_LIST]: (state, action) => {
        return {
            ...state,
            inventoryHistoryDetailList: action.res
        }
    },
    [STORE.TRANSFER_HISTORY_LIST]: (state, action) => {
        return {
            ...state,
            transferHistoryList: action.res
        }
    },
    [STORE.TRANSFER_HISTORY_DETAIL_LIST]: (state, action) => {
        return {
            ...state,
            transferHistoryDetailList: action.res
        }
    },

};

export default createReducer(initialState, actionHandler)